﻿class spell extends MovieClip{
	private var name:String;
	private var type:String;	//click_projectile, omni_cast, environment,
	private var minDamage:Number;
	private var maxDamage:Number;
	private var duration:Number
	
	/**
	 * Default constructor	 */
	public function spell(){
		name = "Spell name not set";
		type = "Spell type not set";
		minDamage = -1;
		maxDamage = -1;
		duration = -1;
	}
	
	/**
	 * Returns the name of this spell
	 * @return the name of this spell	 */
	public function getName():String{
		return name;
	}
	
	/**
	 * Initializes this spell with the specified values
	 * @param n The name of the spell
	 * @param t The type of the spell (eg, click_projectile, omni_cast, environment)
	 * @param minDamage The minimum amount of damage this spell does
	 * @param maxDamage The maximum amount of damage this spell does
	 * @param dur The duration this spell lasts	 */
	public function initSpell(n:String, t:String, min:Number, max:Number, dur:Number):Void{
		name = n;
		type = t;
		minDamage = min;
		maxDamage = max;
		duration = dur;
	}
	
	/**
	 * Returns a clone of this spell	 */
	public function clone():spell{
		var clone:spell = new spell();
		clone.initSpell(name, type, minDamage, maxDamage, duration);
		return clone;
	}
	
	/**
	 * Makes parameter into a copy of this
	 * @param s The spell to be changed	 */
	public function duplicate(s:spell):Void{
		s.initSpell(name, type, minDamage, maxDamage, duration);
	}
	
	function userClick(x:Number, y:Number):Void{
		//the user has clicked at (x,y); do what we need to do
		trace(x + " " + y);
		if(type == "click_projectile")
			trace("click projectile");
		else if (type == "omni_cast"){
			var spellPieces = _root["spellPieces"];
			_root.attachMovie(name, "spell" + _root["spellPieces"], _root["spellDepth"] + _root["spellPieces"], this);
			_root["spell" + spellPieces]._x = x;
			_root["spell" + spellPieces]._y = y;
			_root["spellPieces"]++;
		}
	}
}